#ifndef IMAGEINSTANCE
#define IMAGEINSTANCE

#include <QExplicitlySharedDataPointer>
#include "imageinstancedata.h"
class DicomImage;
class StudyRecord;

class ImageInstance
{
public:
    ImageInstance(const QString &file):
        d(new ImageInstanceData(file)){}
    ImageInstance(DcmFileFormat *dff):
        d(new ImageInstanceData(dff)) {}
    ImageInstance(const ImageInstance &image):
        d(image.d){}

    void setImageType(bool raw) { d->setImageType(raw); }
    void setWindow(const double &center, const double &width)
    { d->setWindow(center, width); }
    void getWindow(double &center, double &width) const
    { d->getWindow(center, width); }
    void setWindowDelta(const double &dCenter, const double &dWidth)
    { d->setWindowDelta(dCenter, dWidth); }
    void setRoiWindow(const QRectF &rect)
    { d->setRoiWindow(rect); }
    void setDefaultWindow() { d->setDefaultWindow(); }
    void setPolarity(EP_Polarity p) { d->setPolarity(p); }
    EP_Polarity getPolarity() const { return d->getPolarity(); }
    bool getPixmap(QPixmap &pixmap) { return d->getPixmap(pixmap); }

    static bool getPixmap(const QString &file, QPixmap &pixmap)
    { return ImageInstanceData::getPixmap(file, pixmap); }
    static bool dcm2bmpHelper(DicomImage &image, QPixmap &pixmap)
    { return ImageInstanceData::dcm2bmpHelper(image, pixmap); }

    bool hasRawImage() const { return d->hasRawImage(); }
    bool isRawImage() const { return d->isRawImage(); }
    bool isNormal() const { return d->isNormal(); }

    DicomImage *createClippedImage(const QRect &rect, int angle = 0, bool hflip = false, bool vflip = false, bool inverted = false)
    { return d->createClippedImage(rect, angle, hflip, vflip, inverted); }
    QStringList getAnnotations() { return d->getAnnotations(); }
    uint getPixelValue(long x, long y, EP_Representation &r) const
    { return d->getPixelValue(x, y, r); }
    bool getPixSpacing(double &spacingX, double &spacingY) const
    { return d->getPixSpacing(spacingX, spacingY); }
    bool getStudyRecord(StudyRecord &studyRec) const
    { return d->getStudyRecord(studyRec); }

    const DicomImage *getDcmImage() const { return d->getDcmImage(); }
    DcmFileFormat *getFileFormat() { return d->getFileFormat(); }
    bool saveFileFormat() { return d->saveFileFormat(); }

    QString patientName() const { return d->patientName; }
    QString studyUid() const { return d->studyUid; }
    QString filePath() const { return d->filePath; }
    QString instanceUid() const { return d->instanceUid; }
    QString seriesUid() const { return d->seriesUid; }
    QString sopClassUid() const { return d->sopClassUid; }
    QString reqPhysician() const { return d->reqPhysician; }
    QString bodyPart() const { return d->bodyPart; }
    QString modelName() const { return d->modelName; }
    QString seriesNumber() const { return d->seriesNumber; }
    QString instanceNumber() const { return d->instanceNumber; }

private:
    QExplicitlySharedDataPointer<ImageInstanceData> d;
};

Q_DECLARE_TYPEINFO(ImageInstance, Q_MOVABLE_TYPE);

#endif // IMAGEINSTANCE
